package com.qf.chat.controller;


import com.qf.chat.commons.base.BaseController;
import com.qf.chat.commons.r.R;
import com.qf.chat.entity.FriendRequest;
import com.qf.chat.entity.vo.RequestHandlerVo;
import com.qf.chat.service.FriendRequestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 好友申请表(FriendRequest)表控制层
 *
 * @author makejava
 * @since 2024-01-12 10:47:51
 */
@RestController
@RequestMapping("/friendRequest")
@Slf4j
public class FriendRequestController extends BaseController<FriendRequestService> {

    @PostMapping("/insert")
    public R insert(@RequestBody FriendRequest friendRequest){
        log.debug("发送好友申请....{}",friendRequest);
        getBaseService().save(friendRequest);
        return R.succ();
    }

    /**
     * 查询所有发送给"我"的好友申请列表
     * @return
     */
    @GetMapping("/query4me")
    public R queryMeRequest(){
        return R.succ(getBaseService().queryMeRequest());
    }

    /**
     * 处理请求
     * @return
     */
    @PostMapping("/handler")
    public R requestHandler(@RequestBody @Validated RequestHandlerVo requestHandlerVo){
        log.debug("处理好友申请....{}",requestHandlerVo);
        return R.succ(getBaseService().requstHandler(requestHandlerVo));
    }
}

